<template>
	<view class="content">
		<view class="title" style="margin-top: 200rpx;">您的工作状况是？</view>

		<picker-view :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view"
			mask-style="background:transparent;">
			<picker-view-column>
				<view class="item" :class="{ select: item == year }" v-for="(item, index) in years" :key="index">
					{{ item.name }}
				</view>
			</picker-view-column>
			<picker-view-column>
				<view class="item" :class="{ select: item == month }" v-for="(item, index) in months" :key="index">
					{{ item.name }}
				</view>
			</picker-view-column>
		</picker-view>

		<zy-register-bottom @next='next'></zy-register-bottom>
	</view>
</template>

<script>
	import RouteUtil from '@/main/common/RouteUtil.js';
	import CacheUtil from '@/main/common/CacheUtil';
	export default {
		data() {
			return {
				data: {},
				years: [],
				year: {},
				months: [],
				month: {},
				value: [0, 0],
				indicatorStyle: `height: 50px;`,
			};
		},
		onLoad() {
			this.data = CacheUtil.getRegisterUser();
			this.requestDict();
		},
		methods: {
			requestDict() {
				uni.$http.get('/api/dict/detail').then(res=>{
					this.years = res.data.dictCareerNodeVos;
					this.months = this.years[0].children;
					this.year = this.years[this.value[0]]
					this.month = this.months[this.value[1]]
					this.data.careerId = this.month.id;
				})
			},
			bindChange: function(e) {
				const val = e.detail.value;
				this.months = this.years[val[0]].children;
				this.data.careerId = this.months[val[1]].id;
				this.year = this.years[val[0]];
				this.month = this.months[val[1]];
			},
			next() {
				CacheUtil.setRegisterUser(this.data)
				RouteUtil.toRegister6()
			}
		}
	};
</script>

<style lang="scss">
	.content {
		width: 100wh;
		height: 100vh;
		margin: 0 50rpx;

		.title {
			font-weight: bold;
			font-size: 48rpx;
			color: #222;
		}

		.picker-view {
			width: 100%;
			height: 600rpx;
			margin: 0 auto;
		}

		.item {
			height: 50px;
			line-height: 50px;
			text-align: center;
			color: #999;
		}

		.item.select {
			color: #222;
			font-size: 36rpx;
			font-weight: 600;
		}
	}
</style>